{% block sw_order_promotion_field %}
<div class="sw-order-promotion-field">
    {% block sw_order_promotion_field_codes %}
    <sw-order-promotion-tag-field
        v-model:value="promotionCodeTags"
        :disabled="!hasLineItem || isLoading || !acl.can('order.editor') || undefined"
        :currency="currency"
        :label="$tc('sw-order.detailsTab.promotionsField.labelPromotions')"
        :placeholder="$tc('sw-order.detailsTab.promotionsField.placeholderPromotions')"
        :error="promotionError"
        @on-remove-code="onRemoveExistingCode"
    />
    {% endblock %}

    {% block sw_order_promotion_field_switch %}
    <h3 class="sw-order-promotion-field__apply_auto_promotions__title">
        {{ $tc('sw-order.detailsTab.promotionsField.automaticPromotions.title') }}
    </h3>

    <p class="sw-order-promotion-field__apply_auto_promotions__text">
        {{ $tc('sw-order.detailsTab.promotionsField.automaticPromotions.text') }}
    </p>

    <mt-button
        :disabled="isLoading || isOrderLoading || !acl.can('order.editor') || undefined"
        class="sw-order-promotion-field__apply_auto_promotions__button"
        variant="secondary"
        size="default"
        :is-loading="isOrderLoading || isLoading"
        @click="applyAutomaticPromotions"
    >
        {{ $tc('sw-order.detailsTab.promotionsField.automaticPromotions.labelButton') }}
    </mt-button>
    {% endblock %}

    {% block sw_order_promotion_field_updates_modal %}
    <sw-modal
        v-if="promotionUpdates.length > 0"
        class="sw-order-promotion-field__updates_modal"
        :title="$tc('sw-order.detailsTab.promotionsField.updatesModal.title')"
        @modal-close="dismissPromotionUpdates"
    >
        <p class="sw-order-promotion-field__updates_modal__description">
            {{ $tc('sw-order.detailsTab.promotionsField.updatesModal.description') }}
        </p>

        <p
            v-show="promotionsAdded.length > 0"
            class="sw-order-promotion-field__updates_modal__list_title"
        >
            {{ $tc('sw-order.detailsTab.promotionsField.updatesModal.promotionAddedTitle') }}
        </p>
        <span
            v-for="(error, idx) in promotionsAdded"
            :key="idx"
            class="sw-order-promotion-field__updates_modal__list_item"
        >
            {{ error.parameters.name }}
            <br>
        </span>

        <p
            v-show="promotionsRemoved.length > 0"
            class="sw-order-promotion-field__updates_modal__list_title"
        >
            {{ $tc('sw-order.detailsTab.promotionsField.updatesModal.promotionRemovedTitle') }}
        </p>
        <span
            v-for="(error, idx) in promotionsRemoved"
            :key="idx"
            class="sw-order-promotion-field__updates_modal__list_item"
        >
            {{ error.parameters.name }}
            <br>
        </span>
    </sw-modal>
    {% endblock %}
</div>
{% endblock %}
